// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
// #pragma expected_value
// #pragma isolated_call
// #pragma disjoint
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using ordered_set = tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define setpre(i) setprecision(i)<<fixed
#define foru(i, a, b) for(int i=a;i<=b;++i)
#define ford(i, a, b) for(int i=a;i>=b;--i)
#define mp make_pair
#define moo cout<<"moo "
#define fi first
#define se second
ll lmod = 1e9 + 7;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int, int> ii;
typedef pair<double, double> dd;
int a[] = {0, 0, 1, 4};
int main(){
#ifdef LOCAL
freopen("input.inp", "r", stdin);
freopen("output.out", "w", stdout);
#endif
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, m; cin >> n >> m;
if(n > m) swap(n, m);
if(n == 1){
cout << m << endl;
return 0;
}
if(n == 2){
cout << m / 4 * 4 + min((m % 4), 2) * 2 << endl;
return 0;
}
if(n == 3){
cout << max({(n / 2 + (n % 2)) * (m / 2 + (m % 2)), m * (1 + (n - 1) / 3), n * (1 + (m - 1) / 3), 4 + (m - 2) / 4 * 5 + a[(m - 2) % 4], (n * m) - (n * m) / 2}) << endl;
return 0;
}
cout << max({(n / 2 + (n % 2)) * (m / 2 + (m % 2)), m * (1 + (n - 1) / 3), n * (1 + (m - 1) / 3), n * m - (n * m) / 2}) << endl;
return 0;
}
198. House Robber | 153. Find Minimum in Rotated Sorted Array |
150. Evaluate Reverse Polish Notation | 144. Binary Tree Preorder Traversal |
137. Single Number II | 130. Surrounded Regions |
129. Sum Root to Leaf Numbers | 120. Triangle |
102. Binary Tree Level Order Traversal | 96. Unique Binary Search Trees |
75. Sort Colors | 74. Search a 2D Matrix |
71. Simplify Path | 62. Unique Paths |
50. Pow(x, n) | 43. Multiply Strings |
34. Find First and Last Position of Element in Sorted Array | 33. Search in Rotated Sorted Array |
17. Letter Combinations of a Phone Number | 5. Longest Palindromic Substring |
3. Longest Substring Without Repeating Characters | 1312. Minimum Insertion Steps to Make a String Palindrome |
1092. Shortest Common Supersequence | 1044. Longest Duplicate Substring |
1032. Stream of Characters | 987. Vertical Order Traversal of a Binary Tree |
952. Largest Component Size by Common Factor | 212. Word Search II |
174. Dungeon Game | 127. Word Ladder |